package com.example.pomelo_home.service.impl;

import com.example.pomelo_home.dao.UserRepository;
import com.example.pomelo_home.entity.User;
import com.example.pomelo_home.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserRepository userRepository;

    public Optional<User> findByOpenid(String openid) {
        return Optional.ofNullable(userRepository.findByOpenid(openid));
    }

    public User save(User user) {
        return userRepository.save(user);
    }
}
